package com.shun.gen;

import cn.hutool.core.io.IoUtil;
import com.shun.gen.service.GenJavaCodeService;
import com.shun.gen.service.GenVueCodeService;
import com.shun.gen.vo.GenConfVO;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 业务代码生成器
 * @author clever
 * @since 2021-09-27
 */
@SpringBootApplication
public class ShunGenCodeApp {

    public static  void  genVueCode() throws IOException {
        GenVueCodeService vueCodeService = new GenVueCodeService();
        vueCodeService.init();
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        GenConfVO genConf = new GenConfVO();
        genConf.setAuthor("clever");
        genConf.setDataTableName("sys_oper_log");
        genConf.setPackageName("com.shun");
        genConf.setTableName("sys_oper_log");
        genConf.setParentPath("D:\\work\\gjydwwork\\frontWork\\gjyd-admin");
        genConf.setPath("com.shun");
        genConf.setModuleName("base");
        genConf.setPathName("operLog");
        genConf.setApiName("sysLog");
        genConf.setSubPathName("SysLog");
        vueCodeService.genCode(genConf,null);
        byte[] data = outputStream.toByteArray();
        FileOutputStream fos = new FileOutputStream(new File("D:\\"+genConf.getPathName()+".zip"));
        IoUtil.write(fos, Boolean.TRUE, data);
    }

    public static void main(String[] args) throws Exception {

        GenJavaCodeService.genCode("gjyd_resource_info","media");

    }
}
